import { Header } from "./components/Header/header"
import { Content } from "./components/Content/content"
import { Footer } from "./components/Footer/footer"
import { useEffect } from "react"
import { useDispatch, useSelector } from "react-redux"
import type { ROOTSTATE } from "./Store"
import { login } from "./Store/userSlice"
import { reqLogin, reqWoami } from "./api/userApi"
import { reqGetAllTypes } from "./api/typeApi"
import { setTypeList } from "./Store/typeSlice"

export const App = () => {
    const dispatch = useDispatch();
    const AllType = async()=>{
        const {data} = await reqGetAllTypes()
        dispatch(setTypeList(data))
    }

    const start = async () => {
        const result = await reqWoami()
        if (result.code != 1) {
            dispatch(login(result.data))
        }
    }

    useEffect(() => {
        start()
        AllType()
    }, [])
    return (
        <>
            <Header></Header>
            <Content></Content>
            <Footer></Footer>
        </>
    )
}